;; supercollider/server-send.scm - (c) rohan drape, 2003-2005

;; Send the OSC byte encoding of a purified Lisp OSC message.

(define (server-send-message message)
  (osc-send-message (server-osc) message))

;; A variant where the time is specified in as a real valued absolute
;; UTC time stamp.

(define (server-send-bundle time messages)
  (osc-send-bundle (server-osc) 
		   (cons (+ time (server-latency)) messages)))

;; Send `message' and wait for the OSC command `return' to be received
;; from the server.  See osc-request for details.

(define (server-request return message)
  (osc-request (server-osc)
	       return
	       message))

;; If `synchronous' is true use `server-request' to send `message',
;; else use `server-send'.  It is important that asynchronous messages
;; be allowed to avoid deadlock in procedures that are called from the
;; server packet engine thread, ie. in response to an incoming OSC
;; message.

(define (server-request* synchronous return message)
  (if synchronous
      (server-request return message)
      (server-send-message message)))

;; Variable argument aliases.

(define (-> . message)
  (server-send-message message))

(define (->< return . message)
  (server-request return message))

(define (=> time . messages)
  (server-send-bundle time messages))

